package ${packageName}.api.service.impl;

import com.alibaba.fastjson.JSONObject;
import ${basePackageName}.constant.BaseRequestModalConstant;
import ${basePackageName}.dto.IdDto;
import ${packageName}.dto.${lowerClassName}.query.${className}QueryDto;
import ${packageName}.dto.${lowerClassName}.input.${className}InputDto;
import ${packageName}.api.service.I${className}Service;
import ${packageName}.service.I${className}ApiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;

@Service
@Slf4j
public class ${className}ServiceImpl implements I${className}Service {

    @Resource
    private I${className}ApiService ${lowerClassName}ApiService;



    @Override
    public Object doBase(String param,String modal) {
        //新增修改方法
        if(BaseRequestModalConstant.METHOD_SAVEORUPDATE.equals(modal)){
            ${className}InputDto ${lowerClassName}InputDto=JSONObject.parseObject(param,${className}InputDto.class);
            return ${lowerClassName}ApiService.saveOrUpdate(${lowerClassName}InputDto);
        }
        //分页方法
        if(BaseRequestModalConstant.METHOD_PAGE.equals(modal)){
            ${className}QueryDto ${lowerClassName}QueryDto=JSONObject.parseObject(param,${className}QueryDto.class);
            return ${lowerClassName}ApiService.getPage(${lowerClassName}QueryDto);
        }
        //删除方法
        if(BaseRequestModalConstant.METHOD_DEL.equals(modal)){
            IdDto idDto=JSONObject.parseObject(param,IdDto.class);
            return ${lowerClassName}ApiService.deleteByPrimary(idDto.getId());
        }
        //get方法
        if(BaseRequestModalConstant.METHOD_GET.equals(modal)){
            IdDto idDto=JSONObject.parseObject(param,IdDto.class);
            return ${lowerClassName}ApiService.getVoByPrimary(idDto.getId());
        }
        return null;
    }

}
